
<script type="text/javascript" language="javascript">
	$(document).ready(function () {
		$.formValidator.initConfig({formID:"addEnterpriseForm",autoTip:false,onError:function(msg){alert(msg)},inIframe:true});
		 $("#txtName").formValidator({onShow:"请输入企业名", onFocus:"企业名不能为空",onCorrect: "　",defaultValue:""}).inputValidator({min:4,max:40,empty:{leftEmpty:false,rightEmpty:false,emptyError:"企业名两边不能有空符号"},onError:"您输入的字符长度非法,请确认"})
			.ajaxValidator({
			dataType : "html",
			type : "POST",
			async : true,
			url : "__URL__/checkEnterpriseName",
			success : function(data){
				if( data == '0' ) {return true};
				return false;
			},
			buttons: $("#button"),
			error: function(jqXHR, textStatus, errorThrown){alert("服务器没有返回数据，可能服务器忙，请重试");},
			onError : "该用企业名已存在，请直接选择",
			onWait : "正在对企业名进行合法性校验，请稍候..."
		});
		$("#uploadLogo").formValidator({onShow:"必须上传企业Logo", onFocus:"此项不能为空",onCorrect: "　",defaultValue:""}).inputValidator({min: 1, onError: "不能为空"});
		$("#txtIntroduce").formValidator({onShow:"企业简介必须填写", onFocus:"此项不能为空",onCorrect: "　",defaultValue:""}).inputValidator({min: 1, onError: "不能为空"});
		$("#txtLinkman").formValidator({empty: true, onShow:"非必填项", onFocus:"请输入您的姓名",onCorrect: "　",defaultValue:""}).inputValidator({min: 1, onError: "长度非法"});
		$("#txtPhone").formValidator({empty: true, onShow:"非必填项", onFocus:"请输入公司座机",onCorrect: "　",defaultValue:""}).regexValidator({ regExp:"tel",dataType:"enum",onError:"你输入的电话格式不正确"});
		$("#txtUrl").formValidator({onShow:"必填项", onFocus:"请输入企业网址，以http://开头",onCorrect: " ",defaultValue:"http://"}).regexValidator({ regExp:"url",dataType:"enum",onError:"你输入的网址格式不正确"});
	});	
</script>
<iframe src="" name="addEnterprises" style="display:none;" ></iframe>
<div style="float:left">
	<form name="addEnterprise" method="post" action="__URL__/addEnterprise" target="addEnterprises" id="addEnterpriseForm" enctype="multipart/form-data">
    <table summary="添加企业" id="box-table-a">
	    <tr>
			<td>企业名称</td>
			<td><input name="txtName" type="text" id="txtName" /></td>
			<td><div id="txtNameTip" style="width: 198px" /></td>
	    </tr>
	    <tr>
			<td>企业Logo</td>
			<td><input type="file" name="uploadLogo" id="uploadLogo" /></td>
			<td><div id="uploadLogoTip" style="width: 198px" /></td>
	    </tr>
	    <tr>
		    <td>企业简介</td>
		    <td>
			   <textarea name="txtIntroduce" rows="2" cols="20" id="txtIntroduce" style="height:100px;width:300px;"></textarea>
			</td>
			<td><div id="txtIntroduceTip" style="width: 198px" /></td>
	    </tr>
	    <tr>
			<td>联系人</td>
			<td><input name="txtLinkman" type="text" id="txtLinkman" /></td>
			<td><div id="txtLinkmanTip" style="width: 198px" /></td>
	    </tr>
	    <tr>
			<td>联系电话</td>
			<td><input name="txtPhone" type="text" id="txtPhone" /></td>
			<td><div id="txtPhoneTip" style="width: 198px" /></td>
	    </tr>
		<tr>
			<td>企业网址</td>
			<td><input name="txtUrl" type="text" id="txtUrl" /></td>
			<td><div id="txtUrlTip" style="width: 198px" /></td>
	    </tr>        
    </table>
	<p style="padding-top: 5px; padding-bottom: 5px; pading-left: 100px;"  >
        <input style="margin-left:230px;" type="submit" name="Button1" value="提交" class="input-button" />
		<input type="button" value="关闭" class="closeload input-button gray" />
	</p>
	</form>
</div>
<script type="text/javascript">
	function insertres(res,id,names){
		if(res){
			var oldhtml=$('#EnterpriseList').html();
			newhtml='<option value="'+id+'" selected="selected" >'+names+'</option>';
			$('#EnterpriseList').html(oldhtml+newhtml);
			$(".load_body").html("");
			$(".ajaxloadhtml").hide();
			alert(names+" 添加成功");
		}else{
			alert('添加失败');
		}
	}
</script>
